package app.srong.service;

import app.srong.mapper.SubTopicMapper;
import app.srong.vo.SubTopic;
import app.srong.vo.SubTopicDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class SubTopicService {

    @Autowired
    SubTopicMapper subTopicMapper;


    public List<SubTopic> subTopicList(Integer topicId) {
        List<SubTopic> topicList = subTopicMapper.subTopicList(topicId);
        for (SubTopic subTopic : topicList) {
            Map<String, String> collect = subTopic.getDetails().stream().collect(Collectors.toMap(SubTopicDetail::getArgeName, detail -> detail.getArgeValue()));
            subTopic.setParams(collect);
        }
        return topicList;
    }
}
